﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using tour.szhome.common;
using tour.szhome.map.DTO;
using TOUR.SZHOME.BLL;

namespace tour.szhome.www.Controllers
{
    public class XiangceController : Controller
    {
        //
        // GET: /Album/
        ProjectsBLL _pbll = new ProjectsBLL();
        LandscapeBLL _lbll = new LandscapeBLL();

        Projects_ImageBLL _pimgbll = new Projects_ImageBLL();
        Landscape_ImageBLL _limgbll = new Landscape_ImageBLL();

        /// <summary>
        /// 相册列表视图
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            //获取楼盘下拉
            ViewBag.PList = _pbll.GetAllProject();
            ViewBag.LList = _lbll.GetAllLandscape();
            //获取景区下拉
            return View();
        }

        /// <summary>
        /// 相册详情
        /// </summary>
        /// <returns></returns>
        public ActionResult Photos(int id = 0)
        {
            ViewBag.ID = id;
            var list = _pimgbll.GetListByXMID(id);
            ViewBag.sList = list.Where(x => x.TPLX == 0).Take(5); //实景图
            ViewBag.xList = list.Where(x => x.TPLX == 1).Take(5); //效果图
            ViewBag.gList = list.Where(x => x.TPLX == 2).Take(5); //规划图
            ViewBag.pList = list.Where(x => x.TPLX == 3).Take(5); //配套图
            ViewBag.hList = list.Where(x => x.TPLX == 4).Take(5); //活动图
            return View();
        }

        /// <summary>
        /// 浏览相册(项目)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Photo_list(int id = 0, int type = 0)
        {
            ViewBag.ID = id;
            ViewBag.uploadAddress = System.Configuration.ConfigurationManager.AppSettings["UploadAddress"];//获取上传文件地址 
            ViewBag.List = _pimgbll.GetList(id, type);
            return View();
        }


        /// <summary>
        /// 浏览相册(景区)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public ActionResult Landspace_Photo_list(int id = 0)
        {
            ViewBag.ID = id;
            ViewBag.uploadAddress = System.Configuration.ConfigurationManager.AppSettings["UploadAddress"];//获取上传文件地址 
            ViewBag.List = _limgbll.GetListByJQID(id);
            return View();
        }

        /// <summary>
        /// 根据Type获取相册列表 
        /// </summary>
        /// <param name="type">1 ： 楼盘相册  2 : 景区相册</param>
        /// <returns></returns>
        [ActionName("get_xiangce_list")]
        public ActionResult GetList(int pid = 0, int lid = 0, int type = 1)
        {
            List<AlbumDTO> list = new List<AlbumDTO>();
            if (type == 1)
            {
                list = _pimgbll.GetList(pid);
            }
            else
            {
                list = _limgbll.GetList(lid);
            }
            return Json(new { list = list, count = list.Count }, JsonRequestBehavior.AllowGet);
        }

    }
}
